package com.ds.robot.assistant.controller;

import com.google.common.cache.LoadingCache;
import com.ds.robot.assistant.entity.ProjectInfoEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 作用：
 *
 * @author WeiShaoying
 * 
 */
@RestController
@RequestMapping("/project")
@Slf4j
public class ProjectController {

    @Resource
    private LoadingCache<String, ProjectInfoEntity> projectCache;


    @GetMapping("/getCache")
    public Map<String, ProjectInfoEntity> getAllCacheContent() {
        try {
            return projectCache.asMap();
        } catch (Exception e) {
            throw new RuntimeException("查询项目缓存异常", e);
        }
    }

}
